package com.base.cn.platform.os.service.upload;

import com.base.cn.platform.os.service.FeignAuthConfig;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

import java.util.List;
import java.util.Map;

/**
 * 文件上传接口
 *
 * @author s.li
 * @create 2018-04-05-19:49
 */
@FeignClient(name = "res",configuration = FeignAuthConfig.class)
public interface FileUploadService {
    String contextPath = "";
    /**
     * 文件上传
     * @param file 文件对象
     * @param fileParams 附带属性，用于剪切图片
     * @return Map<String,Object>
     */
    @RequestMapping(value = contextPath + "/uploadFile",method = {RequestMethod.POST},consumes=MediaType.MULTIPART_FORM_DATA_VALUE)
    Map<String,Object> uploadFile(@RequestPart(value = "file") MultipartFile file,
                                  @RequestParam(value = "fileParams", required = false) String fileParams);

    /**
     * 上传数据流的图片
     * @param imageDataList 数据流列表，每个元素代表一张图片
     * @param params 目录名
     * @return Map<String,Object>
     */
    @RequestMapping(contextPath + "/updateByteFileData")
    Map<String,Object> updateByteFileData(@RequestBody List<Map<String, byte[]>> imageDataList,
                                          @RequestParam("params") String params);

    /**
     * 文件上传用于广告页文件上传
     * @param file 文件对象
     * @param fileParams 附带属性
     * @return Map<String,Object>
     */
    @RequestMapping(value = contextPath + "/advertUploadFile",method = {RequestMethod.POST},consumes=MediaType.MULTIPART_FORM_DATA_VALUE)
    Map<String,Object> advertUploadFile(@RequestPart(value = "file") MultipartFile file,
                                        @RequestParam(value = "fileParams", required = false) String fileParams);

}
